<template>
  <div class="big" v-if="result">
    <div class="back">    
      <div class="name">
      <span class="singers">{{ result.data.artist.name }}</span>
      <span v-if="result.data.identify.imageDesc">{{ result.data.identify.imageDesc }}</span>
      <ul class="se">
        <span v-if="result.data.artist.identifyTag">{{ result.data.artist.identifyTag[0] }}</span>
        <li v-for="se in result.data.artist.identities.length" :key="se">
          <span>{{ result.data.artist.identities[se - 1] }}</span>
        </li>
      </ul>
    </div>
      <div class="black"></div>
      <div class="img"><img :src="result.data.artist.cover" /></div>
    </div>


    <div class="brief">
      <h2>歌手简介</h2>
      <br />
      <div class="desc">{{ result.data.artist.briefDesc }}</div>
    </div>
    <div class="hot" v-if="res">
      <h1>热门单曲</h1>
      <loading v-if="res.songs.length == 0"></loading>
      <music-list
        v-else
        @play="$emit('play', $event)"
        :songlist="songList"
        :shownum="true"
      ></music-list>
    </div>
  </div>
</template>
<script>
import MusicList from "@/components/MusicList";
import Loading from "@/components/Loading";
export default {
  name: "Singer",
  props: {
    id: [String, Number],
  },
  data() {
    return {
      songList: [],
      result: null,
      res: null,
    };
  },
  components: {
    MusicList,
    Loading,
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      vm.axios.get(`/artist/detail?id=${vm.id}`).then((result) => {
        vm.result = result;
        // console.log(result);
      });
    });
    next((vm) => {
      vm.axios.get(`/artist/top/song?id=${vm.id}`).then((res) => {
        vm.res = res;
        let songList = res.songs.map((v) => {
          v.song = {
            privilege: v.privilege,
            artists: v.ar,
            album: v.al,
          };
          return v;
        });
        vm.songList = songList;
      });
    });
  },
};
</script>

<style lang="less" scoped>
.big {
  padding-bottom: 50px;
}
.back {
  position: relative;
  top: 0;
  .black {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    position: absolute;
  }
  .img {
    width: 100%;
    img {
      width: 100%;
      z-index: -1;
    }
  }

}
.brief {
  margin: 10px 2px;
  border-bottom: 2px var(--cy-Color) solid;
  padding: 10px 2px;
  line-height: 18px;
  position: relative;
  h2 {
    font-weight: bold;
    color: rgb(66, 66, 66);
    font-size: 20px;
    line-height: 20px;
  }
  .desc {
    font-size: 14px;
    color: rgb(94, 94, 94);
  }
}
.name {
  position: absolute;
  bottom: 0;
  color: #fff;
  z-index: 4;
  display: flex;
  padding: 10px;
  flex-direction: column;
  span {
    padding: 5px 0;
  }
  .singers {
    font-size: 30px;
    padding-bottom: 10px;
  }
  .se {
    display: flex;
    align-items: baseline;
    span{
      font-size: 14px;
    }
    li {
      span {
        border: 1px white solid;
        border-radius: 6px;
        padding: 0px 3px;
        font-size: 12px;
        margin: 0px 4px;
        opacity: 0.7;
      }
    }
  }
}

.hot {
  h1 {
    padding-bottom: 10px;
    font-size: 25px;
    font-weight: bold;
    color: rgb(66, 66, 66);
    border-bottom: 2px solid var(--cy-Color);
  }
}
</style>